package com.ml.mall.api.order;

import com.ml.mall.annotations.OperLog;
import com.ml.mall.api.BaseController;
import com.ml.mall.bean.base.ApiRestResult;
import com.ml.mall.bean.req.BaseBeanReq;
import com.ml.mall.bean.req.CouponListCheckReq;
import com.ml.mall.bean.req.order.OrderEditReq;
import com.ml.mall.bean.req.order.OrderNewReq;
import com.ml.mall.bean.req.order.OrderQueryPageReq;
import com.ml.mall.consts.PermissionConst;
import com.ml.mall.service.order.SysOrderCoupponService;
import com.ml.mall.service.order.SysOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
* <p>
*  前端控制器
* </p>
*
* @author kyyang
* Created 2021-05-24
*/

@Api(tags = "【order】订单")
@RestController
@RequestMapping("/order/couppon")
public class SysOrderCoupponController extends BaseController{

     @Autowired
     private SysOrderCoupponService sysOrderCoupponService;

    @RequestMapping(method = RequestMethod.POST, path = "/check")
    @ApiOperation("优惠券检测")
//  @RequiresPermissions(PermissionConst.ORDER_COUPPON_CHECK)
    public ApiRestResult sysOrderEdit(@Valid @RequestBody CouponListCheckReq req ) {
        return ApiRestResult.ok(sysOrderCoupponService.checkCouponByCouponCode(req));
    }


    @RequestMapping(method = RequestMethod.POST, path = "/checkSupplierByCouponCode")
    @ApiOperation("检测包邮优惠券对应卖家的supplierId")
    public ApiRestResult checkSupplierByCouponCode(String couponCode) {
        Long aLong = sysOrderCoupponService.checkSupplierByCouponCode(couponCode);
        return ApiRestResult.ok(aLong);
    }
}
